#!/bin/sh

# vidclip
# A Bourne-compatible shell script for clipping a segment of video.
# vidclip takes 3 parameters: a start time, an end position, and
# the video file. The start time may be given in integer seconds, or
# in HH:MM:SS format. The end position may be given in integer seconds,
# or in HH:MM:SS.HU (notice the extra .HU), or a size (ie 500b for 
# 500 bytes, 500kb for 500 kilobytes, or 500mb for 500 megabytes.

if test $# -ne 3; then
    echo "Usage: vidclip [start time] [end position] [infile]"
    echo "e.g., vidclip 0 30 render.avi"
    echo "      [start time] may be an integer (seconds)"
    echo "                   or HH:MM:SS format."
    echo "      [end position] may be an integer (seconds)"
    echo "                   or HH:MM:SS.HU format"
    echo "                   or <size>b|kb|mb to stop at <size>."
    exit 1
fi

IN_POINT="$1"
OUT_POINT="$2"
VID="$3"

mencoder -oac copy -ovc copy -ss $IN_POINT -endpos $OUT_POINT "$VID" -o "clip.$VID"
